<template>
  <div class="footer-bar">
    <nav class="main">
      <router-link to="/home" v-if="page === 'home'" class="fb-item fb-current" id="footer_index">
        <i class="fb-icon-index fb-icon-index-current"></i>
        <span class="link-text">首页</span>
      </router-link>
      <router-link to="/home" v-else class="fb-item" id="footer_index">
        <i class="fb-icon-index"></i>
        <span class="link-text">首页</span>
      </router-link>

      <router-link to="/follow" v-if="page === 'follow'" class="fb-item fb-current" id="footer_follow">
        <i class="fb-icon-follow fb-icon-follow-current"></i>
        <span class="link-text">关注</span>
      </router-link>
      <router-link to="/follow" v-else class="fb-item" id="footer_follow">
        <i class="fb-icon-follow"></i>
        <span class="link-text">关注</span>
      </router-link>

      <li @click="askQuestion" class="fb-item">
        <img id="imgAsk" class="icon-ask" src="../assets/img/img_ask.png" />
      </li>

      <router-link to="/message" v-if="page === 'message'" class="fb-item fb-current" id="footer_message">
        <i class="fb-icon-message fb-icon-message-current"></i>
        <span class="link-text">消息</span>
      </router-link>
      <router-link to="/message" v-else class="fb-item" id="footer_message">
        <i class="fb-icon-message"></i>
        <span class="link-text">消息</span>
      </router-link>

      <router-link to="/me" v-if="page === 'me' " class="fb-item fb-current" id="footer_me">
        <i class="fb-icon-me fb-icon-me-current"></i>
        <span class="link-text">我的</span>
      </router-link>
      <router-link to="/me" class="fb-item" v-else id="footer_me">
        <i class="fb-icon-me"></i>
        <span class="link-text">我的</span>
      </router-link>
    </nav>
    <van-actionsheet v-model="actionShow" :actions="actions" />
  </div>

</template>

<script>

export default {
  name: 'footer-bar',
  data () {
    return {
      actionShow: false,
      actions: [{
        type: 0,
        name: '问答（提出疑问，获得3位点评师专业解答）',
        callback: this.chooseAskType
      }, {
        type: 1,
        name: '点评（上传作品，得到3位点评师专业点评）',
        callback: this.chooseAskType
      }, {
        name: '取消',
        callback: this.cancelAsk
      }]
    }
  },
  props: ['page'],
  methods: {
    askQuestion() {
      this.actionShow = true
    },
    cancelAsk() {
      this.actionShow = false
    },
    chooseAskType(item) {
      this.actionShow = false
      var params = { type: item.type }
      this.$router.push({ name: 'questionRelease', params: params })
    },
  }
}

</script>

<style lang="scss">

.footer-bar {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  height: 3rem;
  background-color: #fff;
  border-top: 1px solid #e5e5e5;
  z-index: 100;
  .icon-ask {
    position: absolute;
    display: inline-block;
    width: 2rem;
    height: 2rem;
    left: 50%;
    bottom: 0;
    -webkit-transform: translate(-50%, 50%);
    transform: translate(-50%, 50%);
  }
  .main {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    overflow: visible;
    height: 3rem;
    background-color: #fff;
    -moz-flex-direction: row;
    -ms-flex-direction: row;
    -o-flex-direction: row;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    flex-direction: row;
    -ms-flex-align: center;
    align-items: center;
    box-align: center;
    -moz-box-align: center;
    -webkit-box-align: center;
    .fb-item {
      position: relative;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      color: #7f7f7f;
      text-align: center;
      text-decoration: none;
      font-size: .55rem;
      -moz-flex-direction: column;
      -ms-flex-direction: column;
      -o-flex-direction: column;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      flex-direction: column;
      -ms-flex: 1;
      flex: 1;
      -webkit-box-flex: 1;
      -moz-box-flex: 1;
    }
    .fb-current {
      color: #ffc100;
    }
    .link-text {
      line-height: 1;
    }
    .fb-icon-index {
      display: inline-block;
      width: 100%;
      height: .9rem;
      background-size: auto 100%;
      background-repeat: no-repeat;
      background-position: 50%;
      margin-bottom: .3rem;
      background-image: url('../assets/icon/icon_home.png');
    }
    .fb-icon-index-current {
      background-image: url('../assets/icon/icon_home_selected.png');
    }
    .fb-icon-follow {
      display: inline-block;
      width: 100%;
      height: .9rem;
      background-size: auto 100%;
      background-repeat: no-repeat;
      background-position: 50%;
      margin-bottom: .3rem;
      background-image: url('../assets/icon/icon_relation.png');
    }
    .fb-icon-follow-current {
      background-image: url('../assets/icon/icon_relation_selected.png');
    }
    .fb-icon-message {
      display: inline-block;
      width: 100%;
      height: .9rem;
      background-size: auto 100%;
      background-repeat: no-repeat;
      background-position: 50%;
      margin-bottom: .3rem;
      background-image: url('../assets/icon/icon_message.png');
    }
    .fb-icon-message-current {
      background-image: url('../assets/icon/icon_message_selected.png');
    }
    .fb-icon-me {
      display: inline-block;
      width: 100%;
      height: .9rem;
      background-size: auto 100%;
      background-repeat: no-repeat;
      background-position: 50%;
      margin-bottom: .3rem;
      background-image: url('../assets/icon/icon_me.png');
    }
    .fb-icon-me-current {
      background-image: url('../assets/icon/icon_me_selected.png');
    }
  }
}

</style>
